<template>
  <div>
    <button @click="onClick(item)" v-for="item in citys" :key="item">{{ item }}</button>
  </div>
</template>

<script>
import getDefaultCity from '../models/getCity'
export default {
  data() {
    return {
      citys: ["武汉", "杭州", "厦门"]
    };
  },
  methods: {
    onClick(e) {
      console.log(e);
      console.log(this.$store.state.city);
      localStorage.setItem('city',e)
      var city = getDefaultCity()
      console.log('city: ', city);
      this.$store.commit('setState',e)
    }
  }
};
</script>

<style scoped>
</style>